package it.omnisong.server.persistence.postgres;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.junit.Test;


public class DataBaseManager {

	static Connection connection;
	
	public static Connection getConnection() throws SQLException {

		if (connection == null) {
			try {
				Class.forName("org.postgresql.Driver");
			} catch (ClassNotFoundException ex) {
				throw new SQLException();
			}
		    connection = DriverManager.getConnection("jdbc:postgresql://localhost/omnisongDB",
                    "postgres", "postgres");
		}
		return connection;
	}
	
	@Test public void getConn() {
		try {
			DataBaseManager.getConnection();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
